package tlog

import (
	"context"
	"encoding/json"
	"fmt"
)

type LoggerWriter interface {
	////
	// Write
	//  @Description: 日志写处理
	//  @param ctx
	//
	Write(ctx context.Context, content *Content, fields ...Field)
}

type loggerWriter struct{}

func NewLoggerWriter() *loggerWriter {
	return &loggerWriter{}
}

func (l *loggerWriter) Write(ctx context.Context, content *Content, fields ...Field) {
	b, err := json.Marshal(content.BuildFields(fields...))
	if err != nil {
		fmt.Printf("loggerWriter log info err %v \n", err)
	} else {
		fmt.Println(string(b))
	}
}
